package com.zsw.security.config;

import com.sun.org.apache.xpath.internal.functions.FuncConcat;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
 * @author 张士伟
 * @date 2020/7/25 18:02
 **/
//swagger2的配置文件，在项目的启动类的同级文件建立，配置文件
@Configuration
@EnableSwagger2
@EnableWebMvc
@ComponentScan(basePackages = {"com.zsw.security.controller"})
/*@ConditionalOnProperty(name = "swagger.enable",  havingValue = "true")*/
public class Swagger2Config {

    /*
    * 配置一些swagger2的一些基本内容
    * 比如扫描的包
    * */
    @Bean
    public Docket customDocket(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo());
    }
    private ApiInfo apiInfo(){
        Contact contact = new Contact("LB","localhost:8080","110960@qq.com");
        return new ApiInfoBuilder()
                .title("swagger入门项目接口")
                .description("API接口")
                .contact(contact)
                .version("1.1.0")
                .build();
    }
    
}
